﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using JM.JCY.Proxy;
using JM.JCY.BusinessEntity.DSJCYD94;
using System.Data;

namespace JM.JCY.SharePointComponent.LawArchives.CaseWarningHome
{
    public partial class CaseWarningHomeUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                using (DSJCYD94Proxy proxy = new DSJCYD94Proxy())
                {
                    //T_AJGL_AJJK_YJAJDataSet.T_AJGL_AJJK_YJAJDataTable dt = proxy.GetTOPFive();


                    //foreach (var item in dt)
                    //{
                    //    item.N_CQTS = (DateTime.Now.Date - item.D_DQRQ.Date).Days.ToString();
                    //    item.AcceptChanges();
                    //}
                    //DataView dv = dt.DefaultView;
                    //DataTable dtDis = dv.ToTable(true, "C_AH", "C_CBBM", "C_CBR", "N_CQTS");
                    //dtDis.DefaultView.Sort = "N_CQTS DESC";
                    //this.gvCaseWarning.DataSource = dtDis.DefaultView;
                    //this.gvCaseWarning.DataBind();
                }
            }
        }

        //protected void lbViewAllDiscussion_Click(object sender, EventArgs e)
        //{
        //    Response.Redirect(SPContext.Current.Site.ServerRelativeUrl + "pages/CaseWarningViewAll.aspx");
        //}

        protected void gvCaseWarning_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                int count = Int32.Parse(e.Row.Cells[3].Text);

                if (count > 0)
                {
                    for (int i = 0; i < e.Row.Cells.Count; i++)
                    {
                        e.Row.Cells[i].ControlStyle.ForeColor = System.Drawing.Color.Red;
                    }
                }
                if (count < 1 && count > -6)
                {
                    for (int i = 0; i < e.Row.Cells.Count; i++)
                    {
                        e.Row.Cells[i].ControlStyle.ForeColor = System.Drawing.Color.Yellow;
                    }
                }
             
            }
        }
    }
}
